package sd.czw.com.miemiegoushop.base;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import butterknife.ButterKnife;
import sd.czw.com.miemiegoushop.utils.CzwNetWorkUtils;
import sd.czw.com.miemiegoushop.utils.loading.CzwLoadingView;

/**
 * Created by czw
 * desc 描述：activity基类
 * on 2017/9/27.
 */
public abstract class CzwBaseActivity extends AppCompatActivity implements CzwBaseCallback {

    @Override
    protected void onStart() {
        super.onStart();
        if (!CzwNetWorkUtils.isConnected(this)){
            Toast.makeText(CzwBaseActivity.this, "无网络连接", Toast.LENGTH_SHORT).show();
        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        CzwBaseActivityStack.getInstance().addActivity(this);
        if (getLayoutId()>0) {
            setContentView(getLayoutId());
        }
        ButterKnife.bind(this);
        initView();
        initData();
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        ButterKnife.unbind(this);
        CzwBaseActivityStack.getInstance().finishActivity();
    }
}
